package com.recycle.service;

import cn.hutool.core.bean.BeanUtil;
import com.recycle.common.ServerResponse;
import com.recycle.dao.CategoryMapper;
import com.recycle.pojo.Category;
import com.recycle.res.CategoryResp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import  java.util.*;
@Service
public class CateGoryService {
    @Autowired
    private CategoryMapper categoryMapper;
    public ServerResponse<List<CategoryResp>> getCategory() {
        List<CategoryResp> categoryRespList = new ArrayList<>();
        List<Category> categoryList = categoryMapper.getCateGroy();
  for(Category category : categoryList){
      CategoryResp categoryResp = new CategoryResp();
      BeanUtil.copyProperties(category,categoryResp);
      categoryRespList.add(categoryResp);
  }
return ServerResponse.SuccessModel(categoryRespList);
    }

}
